package com.wc.alorithm_luogu._贪心.小Z的AK计划;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/29 11:06
 * @description https://www.luogu.com.cn/problem/P2107
 */

public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static long[][] a = new long[N][2];
    static int n;
    static long m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextLong();
        for (int i = 1; i <= n; i++) {
            a[i][0] = sc.nextLong();
            a[i][1] = sc.nextInt();
        }
        Arrays.sort(a, 1, n + 1, Comparator.comparingLong(o -> o[0]));
        PriorityQueue<Long> q = new PriorityQueue<>(Comparator.reverseOrder());
        long sum = 0;
        int res = 0;
        int curRes = 0;
        for (int i = 1; i <= n; i++) {
            sum += a[i][0] - a[i - 1][0];
            // 做这个题
            curRes++;
            sum += a[i][1];
            q.add(a[i][1]);
            while (sum > m && !q.isEmpty()) {
                sum -= q.poll();
                // 把花时间最多的去掉
                curRes--;
            }

            res = Math.max(res, curRes);
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
